-- background: 2767 from stack: in.0 -- bmap block id: 3303 -- flags: 4000 -- background id: 0 -- name: ----- HyperTalk script ----- on domenu which if which is in "about...,New,open...,Save,save as...,revert,print...," & "print code...,show all code,Show code of a line...,Home,add," & "insert,Edit,replace,delete,label above command" then lock screen if which is "About..." then set cursor to watch go cd "about" unlock screen with iris open hide menubar exit domenu end if if which is "open..." then go cd 1 if check_empty() is true then exit domenu open_a_file exit domenu end if if which is "new" then set lockMessages to true go cd 1 if check_empty() is true then exit domenu put empty into cd field "survey" set the scroll of cd field "survey" to 0 put "Untitled" into line 1 of cd field "file" set the width of cd field "file" to 74 set the visible of cd btn "commands" to true go cd "survey file" put "" into cd field "survey file" set the scroll of cd field "survey file" to 0 go cd 1 clearHiliteBtn exit domenu end if if which is "save" then set lockMessages to true if line 1 of cd field "file" = "Untitled" then get save_survey() else go cd 1 put line 2 of cd field "file" into fichier go cd "survey file" WriteToFile cd field "survey file",true,fichier,false,"MACA" go cd 1 end if exit domenu end if if which is "save as..." then get save_survey() exit domenu end if if which is "revert" then answer "Revert to the last saved version?" with "Yes" or "Cancel" if it is "cancel" then exit domenu go cd 1 open_a_file (line 2 of cd field "file") exit domenu end if if which is "print..." then go cd 1 printField "cd field id 1",2,0,0,0,0 exit domenu end if if which is "print code..." then go cd "survey file" printField "cd field id 3",2,36,36,36,36 go cd 1 exit domenu end if if which is "show all code" then go cd "survey file" set the scroll of cd field "survey file" to 0 exit domenu end if if which is "label above command" then unlock screen set the hilite of btn which to not the hilite of btn which label_above set the scroll of cd field "survey" to 0 exit domenu end if if which is "home" then go home exit domenu end if if cd field id 99 is empty and which ≠ "add" then answer "You must select a line first." exit domenu end if if which is "show code of a line..." then put "Please, click on a line to show it's code or click here to cancel." into cd field "header" unlock screen Edit_a_line false exit domenu end if put which into line 1 of cd field "action" put which into line 3 of cd field "action" if which is "Edit" then put "Please, click on the line to Edit or click here to cancel." into cd field "header" unlock screen Edit_a_line true exit domenu end if if which is "delete" then delete_a_line exit domenu end if show cd field "Header" put "Action selected was “" & which & "”. Click on a line or click here to cancel." into cd field "header" show cd field "commandLIST" show cd field "command # list" show cd field "command number" show cd field "label command number" unlock screen put "" into cd field "command number" click at the loc of cd field "command number" else pass domenu end if end domenu on open_a_file fichier set lockMessages to true if fichier = "" then put fileName("TEXT","Select your Survey file...") into fichier if fichier is empty then exit open_a_file go cd 1 put fichier into line 2 of cd field "file" end if clearHiliteBtn show cd field "wait" unlock screen lock screen set the hilite of cd btn "Label above command" to false menuHandler "mark","commands","Label Above Command","none" put empty into cd field "survey" unlock screen lock screen go cd "survey file" put empty into cd field "survey file" open file fichier read from file fichier for 32768 put it into cd field "survey file" set the scroll of cd field "survey file" to 0 close file fichier put verbose() into computed go cd 1 put computed into cd field "survey" set the scroll of cd field "survey" to 0 hide cd field "wait" put realName(fichier) into line 1 of cd field "file" set the visible of cd btn "commands" to true set the width of cd field "file" to (stringWidth(line 1 of cd field "file","Chicago",12))+20 repeat with x = 2 to 5 menuHandler "enable","commands",x end repeat menuHandler "enable","Editor",13 end open_a_file on delete_a_line set cursor to watch set lockMessages to true put item 2 of cd field id 99 into theLine if the shiftKey is up then put line theLine of cd field "survey" into cd field "command selected" show cd btn "delete this command?" show cd field "command selected" show cd btn "yes" show cd btn "cancel" unlock screen set cursor to hand wait until the mouseClick put the clickLoc into clickLic if clickLic is not within the rect of cd btn "yes" then set the hilite of cd btn "cancel" to true wait 5 ticks set the hilite of cd btn "cancel" to false send mouseUp to cd btn "cancel" exit delete_a_line end if set the hilite of cd btn "yes" to true wait 5 ticks set the hilite of cd btn "yes" to false send mouseUp to cd btn "yes" lock screen end if set the hilite of cd btn id (item 1 of cd field id 99) to false put "" into cd field id 99 set cursor to watch delete line theLine of cd field "survey" go cd "survey file" delete line (((theLine-1) * 6) +1) to (theLine * 6) of cd field "survey file" go cd 1 end delete_a_line function save_survey go cd 1 put NewfileName("Save as...",line 1 of cd field "file") into fichier if fichier is empty then return false exit save_survey end if go cd "survey file" WriteToFile cd field "survey file",true,fichier,false,"MACA" go cd 1 put realName(fichier) into line 1 of cd field "file" set the width of cd field "file" to (stringWidth(line 1 of cd field "file","Chicago",12))+20 return true end save_survey on label_above clearHiliteBtn show cd field "wait2" lock screen set cursor to watch put the hilite of cd btn "label above command" into state if state is true then repeat with x = 2 to 5 menuHandler "disable","commands",x end repeat menuHandler "disable","Editor",13 menuHandler "mark","commands","Label Above Command","check" else repeat with x = 2 to 5 menuHandler "enable","commands",x end repeat menuHandler "enable","Editor",13 menuHandler "mark","commands","Label Above Command","none" end if togglePosition state hide cd field "wait2" end label_above function check_empty put false into checked set lockMessages to true go cd "survey file" if cd field "survey file" ≠ "" then answer "Do you want to save this survey?" with "Yes" or "No" or "Cancel" if it is "Yes" then if save_survey() is false then put true into checked end if else if it is "Cancel" then put true into checked end if end if go cd 1 return checked end check_empty on Edit_a_line Edit set cursor to watch lock screen put (item 2 of cd field id 99) into theline put "replace" into line 1 of cd field "action" put theLine into line 2 of cd field "action" put line theline of cd field "survey" into isCR go cd "survey file" put (((theLine-1) * 6) +1) into firstLine put line firstLine of cd field "survey file" into comment put line firstLine+1 of cd field "survey file" into name put line firstLine+2 of cd field "survey file" into tType put line firstLine+3 of cd field "survey file" into text put line firstLine+4 of cd field "survey file" into length put line firstLine+5 of cd field "survey file" into branch go cd 1 put line tType+1 of cd field "commandLIST" into displayString put "0,5,6,8,18,37,38,43,44,45,46" into exceptions repeat with x = 1 to 11 if tType = item x of exceptions then answer "Not available for this command." exit Edit_a_line end if end repeat command tType,displayString put comment into cd field "comment" put length into cd field "length" put name into cd field "name" put branch into cd field "branch" put text into cd field "input" if "with a cr" is in isCR then set the hilite of cd btn id 2 to true -- terminate with a return else set the hilite of cd btn id 2 to false if Edit is false then unlock screen hide cd btn "cancel" hide cd btn "ok" unlock Screen wait until the mouseClick lock screen go cd 1 unlock screen with barn door open end if end Edit_a_line on clearHiliteBtn if cd field id 99 ≠ "" then set the hilite of cd btn id (item 1 of cd field id 99) to false put "" into cd field id 99 end ClearHiliteBtn